<template>
  <EditPetowners :petowner="editp" @submit="updateP"></EditPetowners>
</template>

<script>
import EditPetowners from "@/components/addUpdatePetowners";
export default {
  components: {
    EditPetowners
  },
  created() {
    this.$store.dispatch("Petowners/getPetownersById", this.$route.params.id);
  },
  computed: {
    editp() {
      return this.$store.state.Petowners.PetownersUpdate;
    }
  },
  methods: {
    async updateP(petowner) {
      petowner._id = this.$route.params.id;
      this.$store.dispatch("Petowners/updatePetowners", petowner);
      this.$message({
        message: "修改成功",
        type: "success",
        onClose: () => {
          this.$router.push({
            name: "petowners"
          });
        }
      });
    }
  }
};
</script>
